package com.mall.controller;

import com.mall.pojo.Result;
import com.mall.service.detailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.server.ResponseStatusException;

@RestController
public class detailController {
    @Autowired
    private detailService detailService;
    @RequestMapping("/detail/{id}")
    public Result detail(@PathVariable int id) {
        return Result.success(detailService.getGoodDetails(id));
    }

    @ExceptionHandler(ResponseStatusException.class)
    @ResponseStatus(HttpStatus.UNAUTHORIZED)
    public Result handleResponseStatusException(ResponseStatusException ex) {
        return Result.error(ex.getReason());
    }
}
